package com.dnzx.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.dnzx.framework.page.PageResult;
import org.springframework.stereotype.Service;

import com.dnzx.dao.ICustomizeDao;
import com.dnzx.model.CustomizeBO;
import com.dnzx.service.ICustomizeService;

@Service
public class CustomizeServiceImpl implements ICustomizeService {

    @Resource
    private ICustomizeDao customizeDao;

    @Override
    public void save(CustomizeBO customizeBO) throws Exception {
    	this.customizeDao.save(customizeBO);
    }

    @Override
    public void delete(Long id) throws Exception {
        this.customizeDao.delete(id);
    }

    @Override
    public void update(CustomizeBO customizeBO) throws Exception {
        this.customizeDao.update(customizeBO);
    }
    
    @Override
    public CustomizeBO get(Long id) {
        return this.customizeDao.get(id);
    }
    
    @Override
	public CustomizeBO get(CustomizeBO customizeBO) {
    	List<CustomizeBO> customizeBOList = this.customizeDao.queryList(customizeBO);
    	if (customizeBOList != null && customizeBOList.size() > 0) {
    		return customizeBOList.get(0);
    	}
		return null;
	}
    
    @Override
    public List<CustomizeBO> queryList(CustomizeBO customizeBO) {
        return this.customizeDao.queryList(customizeBO);
    }
    
    @Override
    public PageResult<List<CustomizeBO>> queryPage(CustomizeBO customizeBO, PageResult<List<CustomizeBO>> pageResult) {
    	int totalRows = this.customizeDao.queryCount(customizeBO);
        pageResult.setTotalRows(totalRows);
        pageResult.setCurrentPage(customizeBO.getCurrentPage());
        pageResult.setPageSize(customizeBO.getPageSize());
		List<CustomizeBO> records = this.customizeDao.queryPage(pageResult.getPageSize(), pageResult.getStartRow(), customizeBO);
		pageResult.setT(records);
		return pageResult;
    }
    
}
